package zdc.display {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;

import org.tuio.TuioTouchEvent;

import starling.core.Starling;
import starling.display.Image;

import zdc.ui.MovingInertia;

/**
 * ...
 * @author Metal Slime
 */
public class ImagesQueue extends Sprite {
    var _starling:Starling;
    var _img:Image;

    public function ImagesQueue() {
        stage ? init() : addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event = null):void {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        initVars();
        initState();
        initEvents();
        run();
    }

    private function initVars():void {
        _starling = new Starling(S, stage);

    }

    private function initState():void {

    }

    private function initEvents():void {

    }

    private function run():void {
        _starling.start();
        Helper.initTuio(this);
    }

    public function setImages():void {

    }
}

}

import flash.display.Stage;

import org.tuio.TuioTouchEvent;

import starling.core.Starling;
import starling.display.DisplayObject;
import starling.display.Sprite;
import starling.events.Event;

import zdc.display.SeqImage;
import zdc.ui.MovingInertia;

class S extends Sprite {

    var si:SeqImage;
    var _mi:MovingInertia;

    public function S() {
        var temp:Array = [];
        for (var i:int = 0; i < 126; i++) {
            temp.push("M" + i);
        }
        si = new SeqImage(temp);
        addChild(si);

        addEventListener(Event.ADDED_TO_STAGE, onAdded);
    }

    private function onAdded(e:Event):void {
        removeEventListener(Event.ADDED_TO_STAGE, onAdded);
        var startling:Starling = Starling.current;
        var stage:Stage = startling.nativeStage;
        _mi = new MovingInertia(stage, stage, TuioTouchEvent.TOUCH_DOWN, TuioTouchEvent.TOUCH_UP, TuioTouchEvent.TOUCH_MOVE, TuioTouchEvent.TOUCH_OUT);
        _mi.minWalkDistX = 5;
        _mi.WALK_TYPE = true;
        _mi.addWalkHook(onWalk);
    }

    private function onWalk(e:TuioTouchEvent, cdx:Number, cdy:Number):void {
        if (cdx < 0) {
            si.nextFrame();
            trace("next");
        }
        else {
            si.prevFrame();
            trace("prev");
        }
    }
}